<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html style="font-size: 100px;">
  <head>
    <base href="<%=basePath%>">
    
    <title>智慧消防</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/amazeui.min.css" type="text/css"></link>
	<style type="text/css">
        body{
            background-color: #f1f1f1;
        }
        [data-am-widget=tabs] {
		    margin: 0px;
		    height: 100%;
		}
		li{
			background-color: white;
			border-bottom: 1px solid #eee;
		}
		.am-tabs-bd .am-tab-panel{
			padding: 0px;
		}
		label{
            width:20%;
            white-space:nowrap;
            margin-right: 0.05rem;
		}
	</style>
	<script type="text/javascript">
       function getMaintenanceTask (status){
            $.ajax({
                url: '${linkPath}smartfire/wx/maintenanceTask/getList',
                type: 'get',
                data: {handler: userId, taskStatus: status},
                beforeSend: function(request) {
                    request.setRequestHeader("ACCESS-TOKEN", token);
                },
                success: function(res){
                    var data  = res.obj;
                    var alarm = '';
                    // $('.alarm').html('');
                    for (var i=0;i<data.length; i++) {
                        var taskStatus = data[i].taskStatus;
                        if(taskStatus == '0'){
                            taskStatus = '未处理';
                        } else if(taskStatus == '1'){
                            taskStatus = '处理中';
                        } else if(taskStatus == '2'){
                            taskStatus = '处理完成';
                        }
                    alarm += '<div style="background-color: white;margin-bottom: 1.5px;border: 1px solid #ccc;border-radius: 2px;">';
                    alarm += '<div style="padding: 0 0.2rem;font-size: 0.15rem;height: 0.4rem;line-height: 0.4rem;">';
                    alarm += '<label>任务名：' + data[i].taskTitle + '</label>';
                    alarm += '<span style="float: right;">'+taskStatus+'</span>';
                    alarm += '</div>';
                    alarm += '<div style="border-top: 1px solid #e5e5e5;border-bottom: 1px solid #e5e5e5;padding: 0 0.25rem;">';
                    alarm += '<div style="line-height: 0.25rem;height: 0.25rem;"><label>开始时间:</label> <span style="color: #666666;">'+data[i].startDate+'</span></div>';
                    alarm += '<div style="line-height: 0.25rem;height: 0.25rem;"><label>维保对象:</label>'+data[i].taskObjectName+'</div>';
                        alarm += '<div style="line-height: 0.25rem;height: 0.25rem;"><label>维保地址:</label>'+data[i].taskObjectAddress+'</div>';
                        alarm += '<div style="line-height: 0.25rem;height: 0.25rem;"><label>任务描述:</label>'+data[i].taskDesc+'</div>';
                        alarm += '<div style="line-height: 0.25rem;height: 0.25rem;"><label>创建时间:</label>'+data[i].createDate+'</div>';
                        if(data[i].taskStatus=='2'){
                            alarm += '<div style="line-height: 0.2rem;height: 0.2rem;"><label>处理结果:</label>'+data[i].handleResult+'</div>';
                            alarm += '<div style="line-height: 0.2rem;height: 0.2rem;"><label>附件:</label>'+data[i].attachment+'</div>';
                        }
                        alarm += '</div>';
                        if(data[i].taskStatus != '2') {
                            alarm += '<div style="height: 0.4rem;line-height: 0.4rem;">';
                            alarm += '<div style="right: 0.05rem;top: 0.1rem;color: #fa4b28;">';
                            alarm += '<a style="float: right;border: 1px solid #fa4b28;border-radius: 5px;padding: 8px;margin-right: 0.08rem;margin-top: 0.05rem;line-height: 0.1rem;" href="javascript:(0);" onclick="submitHandleResult(\'' + data[i].id + '\',\'' + data[i].taskTitle + '\')">立即处理';
                            alarm += '</a>';
                            alarm += '</div>';
                            alarm += '</div>';
                        }
                        alarm += '</div>';
                    }
                    if (status == '0') {
                        $('.alarm-1').append(alarm);
                    } else {
                        $('.alarm-2').append(alarm);
                    }

                },
                error: function(error){
                    console.log(error);
                }
            });
        }

	    function submitHandleResult(id,taskTitle){
	    	location.href ='<%=path %>/login/taskHandleResult.jsp?id='+id+'&taskTitle='+ encodeURI(encodeURI(taskTitle));
	    }
	</script>
  </head>
  
  <body onload="getMaintenanceTask('0')">
    <div data-am-widget="tabs" class="am-tabs am-tabs-d2" >
        <ul class="am-tabs-nav am-cf" style="position: fixed;z-index: 1000;width: 100%">
            <li class="am-active"><a onclick="getMaintenanceTask('0')">未处理</a></li>
            <li class=""><a onclick="getMaintenanceTask('2')">已处理</a></li>
        </ul>
      <div class="am-tabs-bd" style="padding: 50px 0;border: 0px">
          <div data-tab-panel-0 class="am-tab-panel am-active alarm alarm-1"></div>
          <div data-tab-panel-1 class="am-tab-panel alarm alarm-2"></div>
      </div>
  </div>
  <div>
	<ul id="common-bottom" class="am-avg-sm-3">
	    <li>
	        <a href="<%=path %>/login/main.jsp"><img class="am-thumbnail" src="<%=path %>/images/nav/home_normal.png"></img>首页</a>
	    </li>
        <li>
            <a><img class="am-thumbnail" src="<%=path %>/images/nav/maintenance_select.png"></img>巡检</a>
        </li>
	    <li>
	        <a href="<%=path%>/login/operationList.jsp "><img class="am-thumbnail" src="<%=path %>/images/nav/operationList_normal.png"></img>维修</a>
	    </li>
        <li>
            <a href="<%=path%>/login/mine.jsp "><img class="am-thumbnail" src="<%=path %>/images/nav/mine_normal.png"></img>我</a>
        </li>
	</ul>
  </div>
  </body>
</html>
